#!/bin/bash


# set -e
# product_out_dir="$1"
# prebuild #
# cd ../../../../device/jieli/ac79n/liteos_m
# CROOT=$(pwd)

# OUTPUT_SRC_DIR=$CROOT/output/bin
# OUTPUT_DST_DIR=$1



# rm $OHOS_LIBS_DIR -rf

# mkdir -p $OHOS_LIBS_DIR
# find $OUTPUT_DST_DIR/libs/ -name '*.a' -exec cp "{}" $OHOS_LIBS_DIR  \;
# #find $CROOT/3rd_sdk/ -name '*.a' -exec cp "{}" $OHOS_LIBS_DIR  \;

# # build #
# make


# export OBJDUMP=/opt/jieli-linux-toolchains-latest/pi32v2/bin/objdump
# export OBJSIZEDUMP=/opt/jieli-linux-toolchains-latest/pi32v2/bin/objsizedump
# export OBJCOPY=/opt/jieli-linux-toolchains-latest/pi32v2/bin/objcopy


# OUTPUT_SRC_DIR=$CROOT/output/bin


# OUTPUT_ELF=${OUTPUT_SRC_DIR}/sdk.elf
# TOOLS=${CROOT}/tools


# ${OBJDUMP} -D -address-mask=0x1ffffff -print-dbg -mcpu=r3 ${OUTPUT_ELF} >  ${OUTPUT_SRC_DIR}/sdk.lst
# ${OBJDUMP} -section-headers -address-mask=0x1ffffff ${OUTPUT_ELF}
# ${OBJSIZEDUMP} -lite -skip-zero -enable-dbg-info ${OUTPUT_ELF} | sort -k 1 > ${OUTPUT_SRC_DIR}/symbol_tbl.txt



# ${OBJCOPY} -O binary -j .text             ${OUTPUT_ELF} ${TOOLS}/text.bin
# ${OBJCOPY} -O binary -j .data             ${OUTPUT_ELF} ${TOOLS}/data.bin
# ${OBJCOPY} -O binary -j .ram0_data        ${OUTPUT_ELF} ${TOOLS}/ram0_data.bin
# ${OBJCOPY} -O binary -j .cache_ram_data   ${OUTPUT_ELF} ${TOOLS}/cache_ram_data.bin

# cd ${TOOLS}
# cat text.bin  data.bin ram0_data.bin cache_ram_data.bin > app.bin 

# isd_download isd_config.ini -tonorflash -dev wl82 -boot 0x1c02000 -div1 -wait 300 -uboot uboot.boot -app app.bin cfg_tool.bin -reboot 500 -update_files normal -formall all




# # after build #
# if [ ! -d $OUTPUT_DST_DIR ]; then
   # mkdir $OUTPUT_DST_DIR
# fi
# cp $OUTPUT_SRC_DIR/* $OUTPUT_DST_DIR/ -rf

